package com.xinggq.common.context;

import java.util.Objects;

/**
 * 用户信息数据类
 * 用于封装用户基本信息，实现模块间的数据传递
 * 
 * @author xinggq
 * @since 2025/1/20
 */
public class UserInfo {

  private Long userId;
  private String username;
  private String realName;
  private String email;
  private Long tenantId;

  /**
   * 默认构造方法
   */
  public UserInfo() {
  }

  /**
   * 全参构造方法
   * 
   * @param userId 用户ID
   * @param username 用户名
   * @param realName 真实姓名
   * @param email 邮箱
   * @param tenantId 租户ID
   */
  public UserInfo(Long userId, String username, String realName, String email, Long tenantId) {
    this.userId = userId;
    this.username = username;
    this.realName = realName;
    this.email = email;
    this.tenantId = tenantId;
  }

  /**
   * 创建测试环境默认用户信息
   * 
   * @return 测试环境默认用户信息
   */
  public static UserInfo createTestUser() {
    return new UserInfo(4001L, "admin", "测试管理员", "admin@test.com", 1L);
  }

  public Long getUserId() {
    return userId;
  }

  public void setUserId(Long userId) {
    this.userId = userId;
  }

  public String getUsername() {
    return username;
  }

  public void setUsername(String username) {
    this.username = username;
  }

  public String getRealName() {
    return realName;
  }

  public void setRealName(String realName) {
    this.realName = realName;
  }

  public String getEmail() {
    return email;
  }

  public void setEmail(String email) {
    this.email = email;
  }

  public Long getTenantId() {
    return tenantId;
  }

  public void setTenantId(Long tenantId) {
    this.tenantId = tenantId;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    UserInfo userInfo = (UserInfo) o;
    return Objects.equals(userId, userInfo.userId) &&
           Objects.equals(username, userInfo.username) &&
           Objects.equals(realName, userInfo.realName) &&
           Objects.equals(email, userInfo.email) &&
           Objects.equals(tenantId, userInfo.tenantId);
  }

  @Override
  public int hashCode() {
    return Objects.hash(userId, username, realName, email, tenantId);
  }

  @Override
  public String toString() {
    return "UserInfo{" +
           "userId=" + userId +
           ", username='" + username + '\'' +
           ", realName='" + realName + '\'' +
           ", email='" + email + '\'' +
           ", tenantId=" + tenantId +
           '}';
  }
}